package Algorthim;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

import searchTree.GlobalData;
import searchTree.searchTreeNode;

public class Soultions extends ArrayList<searchTreeNode>{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
//	private ArrayList<searchTreeNode> list;
	private int setting;
	private GlobalData globalObjRef;
	
	public Soultions(int runSetting,GlobalData global)
	{
		this.globalObjRef = global;
		this.setting = runSetting;
	}
	
	@Override
	public synchronized boolean add(searchTreeNode e) {
		if(setting == Algorithim.FIRST)
		{
			// make all the threads exit gracefully
			globalObjRef.setK(0);
			return super.add(e); //; list.add(e);			
		}
		else if(setting == Algorithim.BEST)
		{
			if(globalObjRef.getK() > e.getNumberOfCuts())
			{
				globalObjRef.setK(e.getNumberOfCuts());
			}
			return super.add(e);
		}
		else
		{
			return super.add(e);
		}
	}
}
